package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class InventoryTurnoverRatio extends Equation {
	
	private double cost_of_goods_sold;
	private double average_inventory;
	
	public InventoryTurnoverRatio(){}
	
	public InventoryTurnoverRatio( double costOfGoodsSole, double averageInventory )
	{
		this.cost_of_goods_sold = costOfGoodsSole;
		this.average_inventory = averageInventory;
		value = ( cost_of_goods_sold / average_inventory );
	}
	

	@Override
	public String getEquationName() {
		return EquationNames.INVENTORY_TURNOVER_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.COST_OF_GOODS_SOLD );
		requiredFields.add( FieldList.AVERAGE_INVENTORY );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		cost_of_goods_sold = values[0];
		average_inventory = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + cost_of_goods_sold +" / " + average_inventory +" ) = " + value;
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.COST_OF_GOODS_SOLD +" / " + FieldList.AVERAGE_INVENTORY +" )";
	}

	@Override
	public void solve() {
		value = ( cost_of_goods_sold / average_inventory );	
	}

}
